package com.hkd.common.api.convert;

import com.hkd.common.api.SysException;
import com.hkd.common.api.enums.PointSource;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @author HKD
 * @date 2022/9/17 20:25
 */
@Component
public class PointSourceConvert implements Converter<Integer, PointSource> {
    @Override
    public PointSource convert(Integer source) {
        return Optional.ofNullable(PointSource.search(source)).orElseGet(() -> {
            throw new SysException("无此积分变动来源");
        });
    }
}
